package com.ai.api.controller;

import com.ai.bo.CandidateBO;
import com.ai.bo.InterviewRecordBO;
import com.ai.grace.result.GraceJSONResult;
import com.ai.service.CandidateService;
import com.ai.service.JobService;
import com.ai.vo.CandidateVO;
import com.ai.vo.JobNameVO;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wst.ai.pojo.candidate.Candidate;

import java.util.List;

@RestController
@RequestMapping("candidate")
public class CandidateController {
    @Autowired
    private CandidateService candidateService;
    @PostMapping("createOrUpdate")
    public GraceJSONResult createOrUpdate(@RequestBody CandidateBO candidateBO){
        candidateService.createOrUpdate(candidateBO);
        return GraceJSONResult.ok();
    }

    /**
     * 获取候选人列表
     * @param interviewRecordBO
     * @return
     */
    @GetMapping("list")
    public GraceJSONResult list(InterviewRecordBO interviewRecordBO){
        PageInfo<CandidateVO> pageInfo = candidateService.candidateList(interviewRecordBO);
        return GraceJSONResult.ok(pageInfo);
    }

    /**
     * 根据id查询候选人
     * @param candidateId
     * @return
     */
    @GetMapping("detail")
    public GraceJSONResult detail(String candidateId){
        Candidate candidate = candidateService.getCandidateById(candidateId);
        return GraceJSONResult.ok(candidate);
    }

    @PostMapping("delete")
    public GraceJSONResult delete(@RequestParam String candidateId){
        candidateService.deleteCandidate(candidateId);
        return GraceJSONResult.ok();
    }
}
